package com.tdkj.model.common;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.persistence.CascadeType;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MapKeyColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.tdkj.model.base.BaseEntity;

/**
 * 
 */
@Entity
@Table(name = "common_type")
public class BeanType extends BaseEntity {

	private String name;
	private String state;
	private Integer level;
	private BeanType parent ;
	private List<BeanType> children = new ArrayList<BeanType>();
	private Map<String,String> prop;
	private String rootName;
	
	private String fullId;
	/**
	 * @return the properties
	 */
	@ElementCollection
	@CollectionTable(name="common_type_properties",
			joinColumns={@JoinColumn(name="type_id",referencedColumnName="id")})
	@MapKeyColumn(name="_key")
	@Column(name="_value")
	public Map<String, String> getProp() {
		return prop;
	}

	/**
	 * @param properties the properties to set
	 */
	public void setProp(Map<String, String> prop) {
		this.prop = prop;
	}
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getState() {
		return this.state;
	}

	public void setState(String state) {
		this.state = state;
	}

	@ManyToOne(fetch=FetchType.LAZY, cascade={CascadeType.REFRESH})
	@JoinColumn(name="parent_id")
	public BeanType getParent() {
		return parent;
	}

	public void setParent(BeanType parent) {
		this.parent = parent;
	}

	@OneToMany(fetch=FetchType.LAZY, cascade={CascadeType.ALL}, mappedBy="parent")
	public List<BeanType> getChildren() {
		return children;
	}

	public void setChildren(List<BeanType> children) {
		this.children = children;
	}

	public Integer getLevel() {
		return level;
	}

	public void setLevel(Integer level) {
		this.level = level;
	}

	public String getRootName() {
		return rootName;
	}

	public void setRootName(String rootName) {
		this.rootName = rootName;
	}

	/**
	 * @return the fullId
	 */
	public String getFullId() {
		return fullId;
	}

	/**
	 * @param fullId the fullId to set
	 */
	public void setFullId(String fullId) {
		this.fullId = fullId;
	}
	
	

}